/**
 * Created by yuyangyang on 2015/1/13.
 */


'use strict';
module.exports = function (grunt) {

    var chalk = require('chalk');

    grunt.registerMultiTask('concatconfig', 'concat config files.', function () {
        var options = this.options();
        var concat = {files: []};

        this.files.forEach(function (file) {
            var obj = {},
                src = file.src.toString() + '/**/*.js',
                dest = file.src.toString() + '.js';
            obj[dest] = src;
            concat.files.push(obj);
            grunt.log.writeln(chalk.cyan(src) + ' concated to ' + chalk.cyan(dest));
        });
        grunt.file.write(options.jsonPath, JSON.stringify(concat));
    });
}